package com.lanxin.oa.basic.dao;
import com.lanxin.base.BaseDaoImpl;
import com.lanxin.bean.JcBasicdatavalue;
import com.lanxin.bean.LcFlow;
import com.lanxin.util.PageBean;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public class BasicDaoImpl extends BaseDaoImpl implements BasicDao {

    @Override
    public PageBean<JcBasicdatavalue> selectJcBasicPage(Integer page, Integer pageSize, JcBasicdatavalue basic) {
        if (page==null){
            page = 1;
        }
        if(pageSize == null){
            pageSize = 5;
        }
        String hql=("from JcBasicdatavalue j where 1=1");
        if(basic.getType()!=null && !"".equals(basic.getType())){
            hql=hql+" and j.type="+basic.getType();
        }
        return super.pageFenYE(hql, page, pageSize);
    }

    @Override
    public List<JcBasicdatavalue> selecctJcBasic() {
        return queryAll("from JcBasicdatavalue");

    }

    @Override
    public JcBasicdatavalue selectLcBasicByName(String name, Integer oid) {
        String hql = "from JcBasicdatavalue b where b.name='" + name + "' ";
        JcBasicdatavalue basic = null;
        if (oid != null) {
            hql = hql + " and b.oid=" + oid;
            basic = (JcBasicdatavalue) selectByHQL(hql);
            if (basic != null) {
                return null;
            }
            basic = (JcBasicdatavalue) selectByHQL("from JcBasicdatavalue b where b.name='"+ name +"'");
            if (basic == null) {
                return null;
            }
        } else {
            return (JcBasicdatavalue) selectByHQL(hql);
        }
        return basic;
    }

    @Override
    public JcBasicdatavalue selectById(Integer oid) {
        return (JcBasicdatavalue) selectByHQL("from JcBasicdatavalue j where j.oid="+oid);
    }

    @Override
    public void delete(Object  o) {
        super.delete(o);
    }

}
